# -*- mode: snippet -*-
# name: save fig in pdf with auto resize
# key: pdf
# --
fig_hl = ${1:figure_handle};
filename = ['${2:filename}', '.pdf'];
set(fig_hl,'Units','Inches');
pos = get(fig_hl,'Position');
set(fig_hl,'PaperPositionMode','Auto','PaperUnits','Inches','PaperSize',[pos(3), pos(4)])
print(fig_hl, filename, '-dpdf', '-r0')
% For transparent, we need use the 3rd-party package: 'export_fig'
% set(gca, 'Color', 'none');
% export_fig -transparent NAME.pdf